package com.itheima.dao;

import com.itheima.domain.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IProductDao {

    /**
     * 查询所有产品信息
     *
     * @return
     */
    @Select("select * from PRODUCT")
    List<Product> findAllProduct();


    /**
     * 添加新产品信息
     *
     * @param product
     */
    @Insert("INSERT INTO PRODUCT (ID, PRODUCTNUM, PRODUCTNAME, CITYNAME, DEPARTURETIME, PRODUCTPRICE, PRODUCTDESC, PRODUCTSTATUS) VALUES (SYS_GUID(), #{productNum}, #{productName}, #{cityName}, #{departureTime}, #{productPrice}, #{productDesc}, #{productStatus})")
    void insertProduct(Product product);

    /**
     * 根据产品id删除产品信息
     *
     * @param id
     */
    @Delete("delete from PRODUCT where id = #{id}")
    void deleteProduct(String id);


    /**
     * 根据产品ID查询产品信息
     *
     * @param productId
     * @return
     */
    @Select("select * from PRODUCT where id = #{productId}")
    Product findProductById(String productId);
}
